﻿using Coldairarrow.Business.PB;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.PB;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.PB
{
    [Route("/PB/[controller]/[action]")]
    public class PB_ProjectLoggingController : BaseApiController
    {
        #region DI

        public PB_ProjectLoggingController(IPB_ProjectLoggingBusiness pB_ProjectLoggingBus)
        {
            _pB_ProjectLoggingBus = pB_ProjectLoggingBus;
        }

        IPB_ProjectLoggingBusiness _pB_ProjectLoggingBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<PB_ProjectLogging>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _pB_ProjectLoggingBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<PB_ProjectLogging> GetTheData(IdInputDTO input)
        {
            return await _pB_ProjectLoggingBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(PB_ProjectLogging data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _pB_ProjectLoggingBus.AddDataAsync(data);
            }
            else
            {
                await _pB_ProjectLoggingBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _pB_ProjectLoggingBus.DeleteDataAsync(ids);
        }

        /// <summary>
        /// 获取当前楼号
        /// </summary>
        /// <param name="input"></param>
        /// <param name="Bulid"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<PageResult<PB_ProjectLogging>> GetDataLogListAsync(PageInput<ConditionDTO> input, string Bulid) {
            var list = await _pB_ProjectLoggingBus.GetDataLogListAsync(input, Bulid);
            return list;
        }


        /// <summary>
        /// 获取协作者数据
        /// </summary>
        /// <param name="input">条件参数</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<PB_ProjectLoggingDto>> GetDataLogDtoListAsync(PageInput<ConditionDTO> input) {

            var list = await _pB_ProjectLoggingBus.GetDataLogDtoListAsync(input);
            return list;
        }
        #endregion
    }
}